Skip to content

Cross-check MirrorOfMatrix - #73

Open
hotasourav8-sketch wants to merge 1 commit into
S-AI-Projects:masterfrom
hotasourav8-sketch:student/e26b07f0855/R45-T023
Open

hotasourav8-sketch wants to merge 1 commit into
S-AI-Projects:masterfrom
hotasourav8-sketch:student/e26b07f0855/R45-T023

Conversation

@hotasourav8-sketch

Copy link
Copy Markdown

Description
This PR introduces property-based cross-check tests for MirrorOfMatrix.mirrorMatrix(). Instead of relying solely on hardcoded arrays, it verifies the fundamental mathematical invariants of matrix reflections, including involution, dimension preservation, index mapping, and row-sum preservation.

Related Issue
Fixes: #23

Type of Change
● Tests

Changes Made

  • Added MirrorOfMatrixCrossCheckTest.java.
  • Verified involution property: mirror(mirror(M)) == M.
  • Verified element mapping formula: mirrored[i][j] == original[i][numCols - 1 - j].
  • Verified row-sum conservation and dimension preservation.
  • Verified fixed-point identity behavior for palindromic rows and single-column matrices.
  • Verified original input matrix immutability.

Screenshots / Recordings
N/A (Backend / Unit test changes only)

Testing
Executed JUnit 5 test suite:
mvn test -Dtest=MirrorOfMatrixCrossCheckTest

Checklist
● I have tested my changes locally.
● I have added or updated tests, if needed.
● I have updated documentation, if needed.
● I have followed the project's coding guidelines.
● I have run the relevant tests and checks.
● I have addressed previous review feedback, if applicable.

Additional Notes
All properties hold across both square and rectangular matrices.

Add property-based cross-check tests for MirrorOfMatrix:
- Verify involution: mirror(mirror(M)) == M
- Verify dimensions are preserved for square and rectangular matrices
- Verify element mapping: mirrored[i][j] == original[i][cols - 1 - j]
- Verify row-sum invariance under horizontal reflection
- Verify identity behavior for single-column matrices and palindromic rows
- Verify original input matrix is not mutated

Fixes: S-AI-Projects#23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sourav Hota — R45-T023: Cross-check MirrorOfMatrix (MirrorOfMatrix.java) [src/main/java/com/thealgorithms/matrix/MirrorOfMatrix.java]

1 participant